<?php

/**
 * Servicio filter form base class.
 *
 * @package    cronos-doctrine
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseServicioFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'empresa_id'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'agendado_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Agendado'), 'add_empty' => true)),
      'servicio_tipo_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ServicioTipo'), 'add_empty' => true)),
      'categoria_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Categoria'), 'add_empty' => true)),
      'producto_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Producto'), 'add_empty' => true)),
      'servicio_status_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ServicioStatus'), 'add_empty' => true)),
      'tamano_id'          => new sfWidgetFormFilterInput(),
      'presentacion_id'    => new sfWidgetFormFilterInput(),
      'codigo'             => new sfWidgetFormFilterInput(),
      'cantidad'           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'nota'               => new sfWidgetFormFilterInput(),
      'precio'             => new sfWidgetFormFilterInput(),
      'impuestos'          => new sfWidgetFormFilterInput(),
      'puntos'             => new sfWidgetFormFilterInput(),
      'fecha_prox'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'fecha_entrega'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'created_at'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'mascota_list'       => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'Mascota')),
    ));

    $this->setValidators(array(
      'empresa_id'         => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'agendado_id'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Agendado'), 'column' => 'id')),
      'servicio_tipo_id'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('ServicioTipo'), 'column' => 'id')),
      'categoria_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Categoria'), 'column' => 'id')),
      'producto_id'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Producto'), 'column' => 'id')),
      'servicio_status_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('ServicioStatus'), 'column' => 'id')),
      'tamano_id'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'presentacion_id'    => new sfValidatorPass(array('required' => false)),
      'codigo'             => new sfValidatorPass(array('required' => false)),
      'cantidad'           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'nota'               => new sfValidatorPass(array('required' => false)),
      'precio'             => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'impuestos'          => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'puntos'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'fecha_prox'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'fecha_entrega'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'created_at'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'mascota_list'       => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'Mascota', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('servicio_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function addMascotaListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.MascotaHasServicio MascotaHasServicio')
      ->andWhereIn('MascotaHasServicio.mascota_id', $values)
    ;
  }

  public function getModelName()
  {
    return 'Servicio';
  }

  public function getFields()
  {
    return array(
      'id'                 => 'Number',
      'empresa_id'         => 'Number',
      'agendado_id'        => 'ForeignKey',
      'servicio_tipo_id'   => 'ForeignKey',
      'categoria_id'       => 'ForeignKey',
      'producto_id'        => 'ForeignKey',
      'servicio_status_id' => 'ForeignKey',
      'tamano_id'          => 'Number',
      'presentacion_id'    => 'Text',
      'codigo'             => 'Text',
      'cantidad'           => 'Number',
      'nota'               => 'Text',
      'precio'             => 'Number',
      'impuestos'          => 'Number',
      'puntos'             => 'Number',
      'fecha_prox'         => 'Date',
      'fecha_entrega'      => 'Date',
      'created_at'         => 'Date',
      'updated_at'         => 'Date',
      'mascota_list'       => 'ManyKey',
    );
  }
}
